package com.push.notnoop.biyao.com;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

import com.notnoop.apns.APNS;
import com.notnoop.apns.ApnsService;


public class Push {
	public static void main(String[] args) {
		String keystore = "F:/circle_workfile/biyaoPush.p12";// 证书路径和证书名
		String password = "biyaoPush"; // 证书密码
		// 手机唯一标识 (郭冲："7b4561a3d2fd1fe7c12b923525b0ec64a59b4b81efc4e9841213ef1a2dc4876e")
		String token = "7b4561a3d2fd1fe7c12b923525b0ec64a59b4b81efc4e9841213ef1a2dc4876e";
		String token1 = "7b4561a3d2fd1fe7c12b923525b0ec64a59b4b81efc4e9841213ef1a2dc487";
		ApnsService service =
			    APNS.newService()
			    .withCert(keystore, password)
			    .withProductionDestination()
			    .build();
		
		String payload = APNS.newPayload().badge(60).alertBody("Can't be simpler than this01!").build();
//		String token = "fedfbcfb....";
//		service.push(token, payload);
		
		String payload2 = APNS.newPayload().badge(60).alertBody("Can't be simpler than this02!").build();
//		service.push(token1, payload2);
		
		
		String token0 = "7b4561a3d2fd1fe7c12b923525b0ec64a59b4b81efc4e9841213ef1a2dc4876e";
		String token2 = "7b4561a3d2fd1fe7c12b923525b0ec64a59b4b81efc4e9841213ef1a2dc4876a";
		
		List<String> list = new ArrayList<String>();
		list.add(token0);
		list.add(token2);
		service.push(list, payload);
		
		
		ApnsService service2 = APNS.newService().withCert(keystore, password).withProductionDestination().build();
		Map<String, Date> inactiveDevices = service2.getInactiveDevices();
		for (String deviceToken : inactiveDevices.keySet()) {
		    Date inactiveAsOf = inactiveDevices.get(deviceToken);
		    
		    System.out.println(inactiveDevices.keySet().toString());
		    System.out.println(inactiveAsOf.toString());
		}
		
	} 
}
